home *** CD-ROM | disk | FTP | other *** search
Emacs RMAIL | 1992-10-12 | 6.9 KB | 247 lines | [TEXT/ttxt] |
- BABYL OPTIONS:
- Version: 5
- Labels:
- Note: This is the header of an rmail file.
- Note: If you are seeing it in rmail,
- Note: it means the file has no messages in it.
- 0, unseen,,
- *** EOOH ***
- Newsgroups: comp.sys.mac.programmer
- Subject: Think C Posix library
- From: tim@maths.tcd.ie (Timothy Murphy)
- Date: Fri, 2 Oct 1992 17:09:08 GMT
- Organization: Dept. of Maths, Trinity College, Dublin, Ireland.
- Keywords: Think C library
- Summary: A small library of Posix functions
-
-
- I recently ported a number of GNU programs to the Mac --
- including perl-4.035, rcs-5.6, diff-2.0 and patch-2.0.12u8 --
- using Think C.
- To avoid repetition, I wrote a library
- called, rather grandiosely, ThinkCPosix or just Posix.
- (I say "wrote", but in fact code for many of the functions
- was collected from PD archives.)
-
- The following note describes what this library is,
- and how it can be obtained and used.
-
- ===================== ThinkCPosix.tex =====================
- \documentstyle[rcs,a4,12pt]{article}
-
- % rcs.sty is available from ftp.uni-stuttgart.de
- % in the directory soft/tex/latex-style-supported .
-
- \RCS$Revision: 1.1 $
- \RCS$Date: 1992/09/14 14:28:23 $
-
- \catcode`\"=\active
- \def"#1"{{\tt #1}}
-
- \begin{document}
-
- \title{A Posix Library for Think C}
-
- \author{Timothy Murphy\\
- Trinity College Dublin\\
- ("tim@maths.tcd.ie")}
-
- \date{\RCSDate\\[2mm]
- (Version \RCSRevision)}
-
- \maketitle
-
- \begin{abstract}
- This library is intended to supplement
- the ANSI and Unix libraries provided with Think C,
- by supplying as many of the missing Posix functions as possible.
- The library was developed to assist in porting
- GNU programs to the Macintosh\footnotemark.
- \end{abstract}
-
- \footnotetext{To date the author has ported
- the following GNU programs to the Mac:
- "diff-1.15",
- "patch-2.012u6",
- "rcs-5.6",
- "bison-1.18",
- "flex-2.3.7",
- "perl-4.035".}
-
- \section{Status}
-
- This library is placed in the Public Domain.
- It may be used and modified freely---%
- though the author would be grateful
- for notification of any such modifications,
- and would prefer if his name and e-mail address
- were left on all files, to this end.
-
- \section{Availability}
-
- The library is available by anonymous FTP from "ftp.maths.tcd.ie"
- in the directory "pub/Mac/ThinkCPosix-1.1".
- The compiled library is contained in the file "Posix.hqx".
- The source files are archived in "ThinkCPosix.hqx".
- This includes the Think C project "Posix.$\pi$".
-
- \section{Acknowledgements}
-
- The author has used freely code in the archives
- pointed out to him,
- in particular code by:
- Guido van Rossum ("guido@cwi.nl"), and
- Mathias Neearcher.
- (Where code is taken more or less verbatim,
- this is indicated in the relevant files.)
-
- He is also grateful for assistance from:
- Kenneth Seah ("kseah@procyon.austin.tx.us"),
- Sak Wathanasin ("sw@network-analysis-ltd.co.uk"),
- John W. Hardin ("hardin@mcc.com"), and
- Gary J. Henderson ("gary@iscnvx.lmsc.lockheed.com")
-
- \section{Posix}
-
- The use of the term ``Posix'' may be misleading---%
- it is certainly not meant to imply that the functions satisfy
- any Posix standards
- (of which the author is largely ignorant).
- It is intended simply as a description
- of the kind of functions included---%
- namely, those Posix functions not included
- in the Think C ANSI or Unix libraries.
-
- Many of the functions
- (in particular those in the file "dummy.c")
- do no more than return an appropriate value,
- indicating success or failure, as deemed appropriate.
-
- \section{Compilation}
-
- To re-compile the library,
- the included project "Posix.$\pi$" can be used.
- Just choose the "Build Library" option
- in the "Project" menu.
-
- The author has all the ANSI options turned on,
- as well as "Require prototypes".
- The 4-byte int option and 68020 code option
- are turned off.
-
- \section{Usage}
-
- Any file using the library should
- \begin{verbatim}
- #include "ThinkCPosix.h"
- \end{verbatim}
- The header ("*.h") files should be placed somewhere
- in the Think C tree (ie below the Think C application).
-
- Whenever the "Posix" library is included,
- the Think C "MacTraps" library must also be included.
- (This could probably be avoided by abstracting
- the very few MacTraps functions called.
- But is that legal?)
-
- \section{Notes}
- These are a few random thoughts on some of the functions
- in the library.
-
- \begin{description}
-
- \item["alloca()"]
- This has been included to avoid duplication.
- Note that the prototype is "void *alloca(size\_t)",
- rather than "char *alloca(unsigned)".
-
- \item["dup()"]
- The functions "dup()" and "dup2()"
- (as implemented here)
- both close the original file after duplication.
- The reason for this is that Think C adopts the non-standard,
- if plausible, policy of including some file-functions
- (such as "close")
- as part of the file structure.
- So a "close(fd)" addressed to the original descriptor
- would also close the duplicate.
- (This may be a misunderstanding on the author's part.)
-
- \item["getpasswd()"]
- This (and one or two other functions)
- call "getlogin()" in the Think C Unix library
- to find the user's name.
- This latter must be set---%
- under System 7, at least---%
- in the "Sharing Setup" Control Panel,
- as described in the Macintosh Networking Reference manual.
- (I believe that under System 6 the username was changed
- on the Chooser panel.)
-
- \item["Open()"]
- The library includes a few ``substitute'' functions,
- eg "Perror()" and "Open()".
- The idea is that these can be used in place of
- "perror()" or "open()" by including the line
- \begin{verbatim}
- #define open Open
- \end{verbatim}
- (or equivalent) at a judicious point in the program---%
- probably at the end of the configuration file,
- "conf.h" or whatever.
-
- The function "Open(char*, int, ...)"
- allows "open()" to take more than 2 arguments
- (as seems increasingly the practice),
- although these extra arguments are ignored.
-
- \item["Perror()"]
- This gives a brief description of the error (if it can)
- rather than just the number as in "perror()".
- The Think C function "strerror()"---%
- which the author had not noticed---%
- may render this unnecessary.
-
- \end{description}
-
- \section{Gnu ports}
-
- In principle the files
- "patch.hqx", "diff.hqx", "perl.hqx", "ci.hqx", etc,
- in the directory "pub/Mac" at "ftp.maths.tcd.ie"
- contain the compiled applications.
-
- The source for these applications---%
- or rather, the diff-files from the standard distributions---%
- are in the appropriate subdirectory,
- eg "pub/Mac/diff-2.0".
-
- Unfortunately, none of these ports are yet documented properly.
-
- \section{Development}
-
- The author would be very grateful
- for any suggested improvements or extensions.
- Please send them to "tim@maths.tcd.ie".
- Any material used will be duly acknowledged.
-
- Implementation of functions related to
- "pipe", "exec" and "spawn"
- would be particularly useful.
- (The "exec()" function in the Think C Unix library
- ignores all arguments except for the application to be launched.
- It would be nice if these arguments could be properly passed---%
- as must surely be feasible.)
-
-
- \end{document}
- ===========================================================
-
-
- --
- Timothy Murphy
- e-mail: tim@maths.tcd.ie
- tel: +353-1-2842366
- s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland